**************************************************************************************
* THIS DO-FILE IDENTIES THE CITIZENSHIP STATUS OF A PARTNER (2020)
* Falcke, S. & Vink, M. (2020). Closing a Backdoor to Dual Citizenship. The German Citizenship Law Reform of 2000.
* do-file written by Swantje Falcke
* November 2020
**************************************************************************************

use ppathl.dta
merge 1:m pid syear using pgen.dta
merge 1:m pid syear using pbruotto, gen(_merge2)

* Information on nationality *
gen nationality=pgnation
replace nationality=. if nationality ==-2 | nationality==-1 | nationality==999
gen nat2=pnat_v2
label list pnat_v2
label values nat2 pnat_v2
replace nat2=. if nat2==-2 |nat2==-1 | nat2=777 | nat2=999
gen natAdd=pnat_v1
label list pnat_v1
label values nat2 pnat_v1
replace natAdd=. if natAdd==9 | natAdd==8 | natAdd==-1 | natAdd==-2 | natAdd==7
replace nat2=natAdd if nat2==. 
replace nationality=nat2 if nationality==. &nat2!=7
gen nationality_r=nationality
label values nationality_r pgnation
sort pid syear
replace nationality_r = nationality_r[_n-1] if missing(nationality_r) 
*Outcome variable: Being German in a respective year*
gen citizenshipGerman=1 if nationality_r==1 
replace citizenshipGerman=0 if nationality_r!=1

keep pid syear citizenshipGerman
rename pid parid
rename citizenshipGerman GermanPartner

save PartnerCitizen.dta
